package com.freedom.sql.jdbc.request;

import java.io.IOException;
import java.io.OutputStream;

import com.freedom.sql.jdbc.pool.socket.MySocket;

public class AutoCommitPacket {
	private int autoCommit;
	private MySocket socket;

	public AutoCommitPacket(MySocket _socket, int _autoCommit) {
		this.socket = _socket;
		this.autoCommit = _autoCommit;
	}

	public void write() throws IOException {
		OutputStream out = socket.getChannel().getOutputStream();
		out.write(new byte[] { 0x11, 0x00, 0x00 });
		out.write(new byte[] { 0x00 });
		out.write(new byte[] { 0x03 });// query
		out.write(("SET autocommit=" + this.autoCommit).getBytes());
		out.flush();
	}
}
